/**
 * 
 */
package com.alstudio.utils.formater.age;

import java.util.Calendar;

import com.alstudio.app.ALLocalEnv;
import com.loovee.imaohu.R;

import android.text.TextUtils;

/**
 * @author alonso lee
 * 
 */
public class ALAgeFormatter {

	/**
	 * 获取年龄
	 * 
	 * @param birthday
	 * @return
	 */
	public static String getAge(String birthday) {
		if (!TextUtils.isEmpty(birthday) && birthday.indexOf("-") != -1) {

			birthday = birthday.substring(0, birthday.indexOf("-"));

			Calendar now = Calendar.getInstance();
			birthday = (now.get(Calendar.YEAR) - Integer.parseInt(birthday))
					+ "";
		}
		return birthday;
	}

	/**
	 * 输出XX岁 | XX地区的字符串
	 * 
	 * @param birthday
	 * @param location
	 * @return
	 */
	public static String getAgeLocation(String birthday, String location) {
		String tmp = "";

		String age = birthday;
		age = String.format(
				ALLocalEnv.getLocalEnv().getString(R.string.TxtAge),
				ALAgeFormatter.getAge(birthday));
		tmp = String.format(
				ALLocalEnv.getLocalEnv().getString(R.string.TxtAgeLocation),
				age, location);

		return tmp;
	}

	/**
	 * 获取星座
	 * 
	 * @param birthday
	 * @return
	 */
	public static String getConstellations(String birthday) {
		String constellations = "";
		if (!TextUtils.isEmpty(birthday) && birthday.indexOf("-") != -1) {
			constellations = new ConstellationUtil()
					.calculateConstellation(birthday);
		}
		return constellations;
	}

}
